<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <p v-bind:title="value | filterA">这是标签</p>
    <p>{{value2 | filterA}}</p>
    <p>{{value2 | filterA | filterB}}</p>
    <p>{{value2 | filterA | filterB}}</p>
    <p>{{value2 | filterC(12)}}</p>
  </div>
  <div id="app2">
    <p>{{value | filterA}}</p>
  </div>
</body>
<script src="../lib/vue.js"></script>
<script>
  Vue.filter("filterA", function(value){
    return value.split("-").join("") + "全局"
  })

  Vue.filter("filterB", function(value){
    return value[0].toUpperCase() + value.slice(1)
  })

  Vue.filter("filterC", function(p1, p2 ,p3){
    // P1是传递过来的值,p2 = 12
    return p2 + "=" + p1
  })

  new Vue({
    el: "#app2",
    data: {
      value: "a-b-c-d"
    },
    filters:{
      filterA(value){
        return value.split("-").join("") + "局部";
      } 
    } 
  })

  new Vue({
    el: "#app",
    data:{
      value: 'a-b-c',
      value2: 'x-y-z'
    }
  })
</script>
</html>